package com.pre;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
/**
 * 过滤器
 * 
 * @author 37798955@qq.com
 *
 */
public class Filter1  implements Filter {
	public Filter1() {
		  System.out.println("实例化过滤器1");
		}

	
  public void destroy() {
      System.out.println("Stopping filter1");
  }

  public void doFilter(ServletRequest request, ServletResponse response,
          FilterChain chain) throws IOException, ServletException {
  	
      System.out.println("调用过滤器1: " + request);

      chain.doFilter(request, response);
  }

  public void init(FilterConfig filterConfig) throws ServletException {
  	 System.out.println("初始化过滤器1");
//      Enumeration<String> enums = filterConfig.getInitParameterNames();
//
//      while (enums.hasMoreElements()) {
//          String param = (String) enums.nextElement();
//          System.out.println(param + ":" + filterConfig.getInitParameter(param));
//      }
  }
}
